class MuasamController < ApplicationController
  def index
    @muasam1 = Giohang.where(:status => "1")
    
  end

  def themvaogio
    #@product = Product.find(params[:product_id])
    @product = Product.find(9)
    if(@product)
      if(current_user)
        @muasam = Giohang.new
        @muasam.status = 1;
        @muasam.productid = @product.id
        @muasam.userid = current_user.id
        @muasam.save
        redirect_to :back
      else

      end
    else
    end
  end

  def trasanpham
    #@product = Product.find(params[:product_id])
    
    @muasam = Giohang.find(1)
   
    if(@muasam)
      if(current_user)
        
        @muasam.update_attributes(:status=>"2");
        redirect_to :back
      else

      end
    else
    end
  end

  def muagiohang
    @muasam = Giohang.where(:status=>"1")
   
    @muasam.each do |sanpham|
      if(current_user)
        
        sanpham.update_attributes(:status=>"3");
        
      else

      end
    end
    redirect_to root_path
  end
end
